* Figure AIII

* Option 1: do not replace anything
preserve
drop extension
gen extension = Extension
replace extension = expire if extension == 0
tab extension, mis
drop timex femx_* Timex postex*
gen timex = year - extension
tab timex, mis
forvalues n = 1/ `r(r)' {
local z = `n' - 6
local k = `n' + 4
gen femx_`k' = female * (timex == `z')
replace femx_`k' = . if timex == .
label var femx_`k' "`z'"
}
gen postexp = year > expire
replace postexp = . if expire == .
gen postext = year > ext
replace postext = . if ext == .
capt egen Timex = group(timex)
label var zero "-1"

eststo option1: reghdfe logsalary femx_5-femx_9 zero femx_11-femx_15 female if timex > -7, a($exp i.extension##i.year) vce(cluster district_code)
restore
	
* Option 2: replace both expirations and extensions
preserve
replace expire = 2011 if expire == .
replace extension = expire if expire != . & extension == .
tab extension, mis
drop timex femx_* Timex postex*
gen timex = year - extension
tab timex, mis
forvalues n = 1/ `r(r)' {
local z = `n' - 6
local k = `n' + 4
gen femx_`k' = female * (timex == `z')
replace femx_`k' = . if timex == .
label var femx_`k' "`z'"
}
capt egen Timex = group(timex)
label var zero "-1"
gen postexp = year > expire
replace postexp = . if expire == .
gen postext = year > ext
replace postext = . if ext == .

eststo option2: reghdfe logsalary femx_5-femx_9 zero femx_11-femx_15 female if timex > -7, a($exp i.extension##i.year) vce(cluster district_code)
restore

* Option 3: baseline
eststo option3: reghdfe logsalary femx_5-femx_9 zero femx_11-femx_15 female if timex > -7, a($exp i.extension##i.year) vce(cluster district_code)

* Build graph
coefplot	(option1, label("no imputation") lcolor("$ylight") lw(thick) fcolor(none) mcolor("$ylight") recast(connect) ciopts(lcolor("$ylight %80") recast(rcap)))   ///
			(option3, label("missing ext = no ext (baseline)") lcolor("$ylb") lw(thick) lp(dash) fcolor(none) mcolor("$ylb") recast(connect) ciopts(lcolor("$ylb %80") recast(rcap)))   ///
			(option2, label("missing exp = 2011; missing ext = no ext") lcolor("$yaleblue") lp(shortdash) lw(thick) fcolor(none) mcolor("$yaleblue") recast(connect) ciopts(lcolor("$yaleblue %80") recast(rcap)))   ///
			 , vert keep(femx_3 femx_4 femx_5 femx_6 femx_7 femx_8 femx_9 zero femx_10 femx_11 femx_12 femx_13 femx_14 femx_15) omitted yline(0, lcolor(gs10) lw(vthin)) xline(6.5) ///
			 level(95) ytitle("conditional salary (100*log)") xtitle("time to CBA expiration/extension") $graph legend(title("assumption for missing expirations/extensions:")pos(6) row(1))
graph export "$out/gap_byassumption.png", replace	
